import QtQuick3D 1.15
import QtQuick 2.15
import QtQuick3D.Materials 1.15
import QtQuick.Window 2.12

import CacheSetter 1.0

import "./common/"

// F11 显示隐藏菜单

Item {
    id: root
    width: Screen.width
    height: 720

    Rectangle{
        anchors.fill: parent
        color: Qt.rgba(46/255, 47/255, 48/255, 1)
    }

    property alias camera: camera

    View3D {
        id: view3D
        anchors.fill: parent

        property alias customNode: customNode

//        CacheSetter {
//            myView: view3D
//        }

        environment: SceneEnvironment {
            antialiasingMode: SceneEnvironment.SSAA
            antialiasingQuality: SceneEnvironment.VeryHigh
        }

        DirectionalLight {
            id: light
            color: "#a6a6a6"
            ambientColor: "#a6a6a6"
            brightness: 70
        }

        PerspectiveCamera {
            id: camera
            fieldOfView: 60
            fieldOfViewOrientation: PerspectiveCamera.Vertical
        }

        // 地面
        Model{
            id: grand
            source: "#Rectangle"
            castsShadows: false
//            receivesShadows: false
            pickable: false

            materials: DefaultMaterial {
                diffuseMap: Texture {
                    source: "qrc:/images/image/bg.png"
                }
            }
        }

        // 报警图标
        Model{
            id: modelIcon
            source: "#Rectangle"
            castsShadows: false
            pickable: false

            materials: DefaultMaterial {
                diffuseMap: Texture {
                    source: "qrc:/images/image/fa.png"
                }
            }

            SequentialAnimation on eulerRotation.z {
                running: true
                loops: -1
                NumberAnimation{ from: 0; to: 360; duration: 10000; }
            }
        }

        CustomNode{
            id: customNode

            SequentialAnimation on eulerRotation.z {
                running: true
                loops: -1
                NumberAnimation{ from: 0; to: 360; duration: 10000; }
            }
        }
    }

    SceneControl{
        id: sceneControl
    }

    MyKeyword{
        id: myKeyword
    }
}
